<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="vue.js"></script>
</head>

<body>
  <div id="app">
    <input type="text" v-focus="'你好'">
  </div>
  <script>
    /* Vue.directive("focus", {
      inserted(el, binding) { //在 指令绑定的 元素 插入到dom时调用
        el.focus();
        console.log(binding);
      }
    }) */
    new Vue({
      el: "#app",
      directives: {
        focus: {
          inserted(el, binding) { //在 指令绑定的 元素 插入到dom时调用
            el.focus();
            console.log(binding);
          }
        }
      }

    })
  </script>
</body>

</html>